import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/widgets/app/app_shop_activity.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class ShopActivityListPage extends StatefulWidget {
  const ShopActivityListPage({Key? key}) : super(key: key);

  @override
  State<ShopActivityListPage> createState() => _ShopActivityListPageState();
}

class _ShopActivityListPageState extends State<ShopActivityListPage> {
  final controller = Get.find<ShopActivityListController>();
  final state = Get.find<ShopActivityListController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
      child: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: AppBar(
          title: Text('商家动态'),
        ),
        body: Obx(() => _buildBody()),
      ),
    );
  }

  _buildBody() {
    return Padding(
      padding: EdgeInsets.only(
          left: AppTheme.iDefaultPadding, right: AppTheme.iDefaultPadding,bottom: AppTheme.iDefaultPadding),
      child: EasyRefresh(
        // 下拉样式
        header: TDRefreshHeader(),
        footer: TaurusFooter(),
        child: Column(
          children:
          state.shopActivityList.map((e) => AppShopActivity(shopActivity: e)).toList(),
        ),
        // 下拉刷新回调
        onRefresh: controller.onRefresh,
        onLoad: controller.onLoad,
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<ShopActivityListController>();
    super.dispose();
  }
}